//
//  WXPFaceErrorExampleView.m
//  MexicoLoan
//
//  Created by wxp on 2025/2/27.
//

#import "WXPFaceErrorExampleView.h"

@implementation WXPFaceErrorExampleView

#pragma mark - lazy
- (UILabel *)labelTitle{
    if (_labelTitle == nil) {
        _labelTitle = [UILabel new];
        _labelTitle.textColor = COLOR_BLACK;
        _labelTitle.fontNum = 14;
    }
    return _labelTitle;
}

#pragma mark - 初始化
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.widthHeight = XY(SCREEN_WIDTH, 0);
        self.backgroundColor = [UIColor clearColor];
        [self configUI];
    }
    return self;
}

- (void)configUI{
    [self addSubview:self.labelTitle];
    [self resetView];
}

#pragma mark - 刷新View
- (void)resetView{
    [self.labelTitle fitTitle:@"Razonamiento frecuente de fracaso" variable:0];
    self.labelTitle.leftTop = XY(LEFT_MARDIN, 0);
    CGFloat viewWidth = (SCREEN_WIDTH-4*LEFT_MARDIN)/3;
    NSArray * array = @[@"No gafa de sol",@"No sombrero",@"Falta iluminación"];
    NSArray * imageArray = @[@"icon-face-error-example-1",@"icon-face-error-example-2",@"icon-face-error-example-3"];
    for(int i = 0; i < array.count; i ++){
        UIView * view = [UIView new];
        view.widthHeight = XY(viewWidth, 0);
        view.leftTop = XY((SCREEN_WIDTH-3*viewWidth)/2+viewWidth*i, self.labelTitle.bottom+20);
        [self addSubview:view];
        
        UIImageView * image = [UIImageView new];
        image.widthHeight = XY(72, 72);
        image.image = [UIImage imageNamed:imageArray[i]];
        image.centerXTop = XY(view.width/2, 0);
        [view addSubview:image];
        
        UILabel * label = [UILabel new];
        label.fontNum = 12;
        label.textColor = COLOR_BLACK;
        [label fitTitle:array[i] variable:0];
        label.centerXTop = XY(image.centerX, image.bottom+Ratio(6));
        [view addSubview:label];
        view.height = label.bottom+1;
        if(i == 0){
            self.height = view.bottom+1;
        }
    }
}

@end
